//
//  MKMusicTool.m
//  singForYou
//
//  Created by nicolas on 2016/12/14.
//  Copyright © 2016年 nicolas. All rights reserved.
//

#import "MKMusicTool.h"

@interface MKMusicTool ()

@property (strong, nonatomic) NSDateFormatter *dateFormatter;

@end

@implementation MKMusicTool

- (NSString *)formatterTimeWithTimeInterval:(NSTimeInterval)timeInterval {
    
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:timeInterval];
    return [self.dateFormatter stringFromDate:date];
    
}

- (NSTimeInterval)timeIntervalWithFormatterTime:(NSString *)formatterTime {
    
    self.dateFormatter.dateFormat = @"mm:ss.SS";
    
    NSDate *currentDate = [self.dateFormatter dateFromString:formatterTime];
    
    NSDate *standardDate = [self.dateFormatter dateFromString:@"00:00.00"];
    
    NSTimeInterval interval = [currentDate timeIntervalSinceDate:standardDate];
    
    return interval;
}

- (NSDateFormatter *)dateFormatter {
    
    if (!_dateFormatter) {
        _dateFormatter = [[NSDateFormatter alloc] init];
        _dateFormatter.dateFormat = @"mm:ss";
    }
    return _dateFormatter;
}




@end
